﻿<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Login - Swim System</title>
		<link rel="shortcut icon" href="favicon.ico">
		<link href="/swimpool-ssm/back/resources/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
		<link href="/swimpool-ssm/back/resources/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
		<link href="/swimpool-ssm/back/resources/css/animate.min.css" rel="stylesheet">
		<link href="/swimpool-ssm/back/resources/css/style.min.css?v=4.0.0" rel="stylesheet">
		<!--[if lt IE 8]>
		    <meta http-equiv="refresh" content="0;ie.html" />
		    <![endif]-->
		<script>
			if (window.top !== window.self) {
				window.top.location = window.location;
			}
		</script>
		<script src="/swimpool-ssm/back/resources/js/jquery.min.js?v=2.1.4"></script>
		<script src="/swimpool-ssm/back/resources/js/bootstrap.min.js?v=3.3.5"></script>
		<script src="/swimpool-ssm/js/util.js"></script>
	</head>
	<body class="gray-bg" style="background-image:url('/swimpool-ssm/img/11.png'); background-repeat: no-repeat ; background-size:cover;">
		<div class="middle-box text-center loginscreen  animated fadeInDown">
			<div>
				<!-- <div>
					<h1 class="logo-name">Swim System</h1>
				</div> -->
				<h3>Swim System Login</h3>
				<form class="m-t" role="form" id="form">
					<div class="form-group">
						<input type="email" name="email" id="email" class="form-control" placeholder="email"
							required="">
					</div>
					<div class="form-group">
						<input type="password" name="password" id="password" class="form-control" placeholder="password"
							required="">
					</div>
					<div class="form-group">
						<select name="usersType" id="usersType" class="form-control">
							<option value="0">users</option>
							<option value="1">staff</option>
							<option value="2">admins</option>
						</select>
					</div>
					<button type="button" id="login" class="btn btn-primary block full-width m-b">Login</button>
					<p class="text-muted text-center">
						<a href="/swimpool-ssm/back/register.html">register</a>
					</p>
					<div class="form-group">
						<span id="info"></span>
					</div>
				</form>
			</div>
		</div>
	</body>
</html>
<script type="text/javascript">
	$('#login').click(function() {
		var postParam = $("#form").serialize();
		//console.info("===postParam==" + postParam)
		/* 提交数据 */
		$.post(
			rootPath + "/login.mvc",
			postParam,
			function(data){
				console.info(data + "==data===" + JSON.stringify(data));
				if(data.code == 0 )
				{
					/* 存储数据 */
					/* setData("adminsInfo",JSON.stringify(data.data.one) );
					
					var data = getData("adminsInfo")
					console.info(data + "==aaa===" + JSON.parse(data)); */
					var usersType = $("#usersType").val();
					if(usersType == '0')
					{
						/* 用户 */
						setData("users",JSON.stringify(data.data.one) );
						openUrl("/back/admins/users_main.html");
					}else if(usersType == '1')
					{
						/* 员工  */
						setData("staff",JSON.stringify(data.data.one) );
						openUrl("/back/admins/staff_main.html");
					}else if(usersType == '2')
					{
						/* 管理员 */
						setData("admins",JSON.stringify(data.data.one) );
						openUrl("/back/admins/main.html");
					}
				}else
				{
					$("#info").html(data.info);
					$("#info").show();
				}
			},
			"json"
		);
		return false ; 
	});
</script>